<?php
use Sow\bug as Y;
class cache{
    public static function section( $id ) {
        $hotnews      = self::fecthURL(OPEN.'home/section/sectionid/'.$id);
        return json_decode($hotnews);
    }   
    public static function api( $url ) {
        $api      = self::fecthURL($url);
        return json_decode($api,true);
    } 
    public static function restApp( $id ) {
        $restApp      = self::fecthURL(OPEN.'section/app/sectionid/'.$id);
        return json_decode($restApp,true);
    } 
    public static function restNews( $id ) {
        $restNews      = self::fecthURL(OPEN.'section/news/sectionid/'.$id);
        return json_decode($restNews,true);
    } 
    public static function search($uri){
        $restSearch      = self::fecthURL(ELASTIC.'search/'.$uri);
        return json_decode($restSearch,true);
    }
    private static function fecthURL($url) {
         $opts =array(
            'http'=>array(
                    'method'=>'GET',
                    'timeout'=>30
                )            
        );  
        $context = stream_context_create($opts);
        return file_get_contents($url,false,$context);
    }
}
